import pkRequest from '@/service/index'
import type {
  IHomeHospitalCard,
  IHomeHospitalTabLevel,
  ISearchHospitalRes
} from './type'

enum API_HOME {
  HOME_HOSPITAL_TAB_LEVEL = '/api/cmn/dict/findByDictCode',
  HOME_HOSPITAL_CARD_LIST = '/api/hosp/hospital',
  SEARCH_HOSPITAL_BY_NAME_URL = '/api/hosp/hospital/findByHosname'
}

// 发送网络请求
// 数据类型
// home页 医院 等级 以及 地区
export const reqHomeHospitalTabLevelData = (dictCode: string) =>
  pkRequest.get<IHomeHospitalTabLevel>({
    url: API_HOME.HOME_HOSPITAL_TAB_LEVEL + `/${dictCode}`
  })
// home页 医院卡片数据
export const reqHomeHospitalCardListsData = (
  page: number,
  limit: number,
  hostype = '',
  districtCode = ''
) => {
  return pkRequest.get<IHomeHospitalCard>({
    url:
      API_HOME.HOME_HOSPITAL_CARD_LIST +
      `/${page}/${limit}?hostype=${hostype}&districtCode=${districtCode}`
  })
}

// 搜索 根据医院名搜索 /api/hosp/hospital/findByHosname/{hosname}
export const reqSearchHospitalsByName = (hosname: string) =>
  pkRequest.get<ISearchHospitalRes>({
    url: API_HOME.SEARCH_HOSPITAL_BY_NAME_URL + `/${hosname}`
  })
